<template>
  <link type="text/css" rel="stylesheet" href="/assets/css/style.css">
  <link rel="stylesheet" href="/assets/css/retailmember.css">
    <div class="retailmember">
        <li v-for="(item, index) in list" :key="index">
            <div class="item" >
                <div class="left">
                    <div class="img">
                        <img :src="item.avatar" alt="">
                    </div>
                    <div class="content">
                        <div class="nickname">{{item.name}}</div>
                        <div class="tel">{{item.mobile}}</div>
                    </div>
                </div>
                <div class="right">{{item.createtime}}</div>
            </div>
      </li>
    </div>
</template>

<script setup>
    const {proxy} = getCurrentInstance()

    let business = proxy.$business

    //分销会员列表
    let list = reactive([])

    //当页面一加载进来的时候就触发的挂载前生命周期钩子函数
    onBeforeMount(()=>{
        RetailList()
    })

    const RetailList = async () =>
    {
        //发起请求
        var result = await proxy.$POST({
            url: '/team/index',
            params: {
                busid: proxy.$business.value.id
            }
        })

        //要么是出错 要么没有数据
        if(result.code == 0)
        {
            proxy.$fail(result.msg)
            return false
        }

        result.data.map((item)=>{
            //重组分销会员结构
            list.push({
                name: item.nickname,
                mobile: item.mobile,
                avatar: item.avatar_text,
                createtime: item.createtime_text
            })
        })
    }
</script>